package com.study.interceptor;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @ClassName Myinterceptor
 * @Description TODO
 * @Author ThinkPad
 * @Date 2020/11/10 20:11
 * @Version 1.0
 **/
@Slf4j
public class MyInterceptor implements HandlerInterceptor {

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
//        System.out.println("正在执行Interceptor中的preHandle方法");
        log.info("正在执行Interceptor中的preHandle方法");
        return true;
    }

    @Override
    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
//        System.out.println("正在执行Interceptor中的postHandle方法");
        log.info("正在执行Interceptor中的postHandle方法");
    }

    @Override
    public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
//        System.out.println("正在执行Interceptor中的afterCompletion方法");
        log.info("正在执行Interceptor中的afterCompletion方法");
    }
}
